package org.apache.lucene.ocean;

import java.io.Reader;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;

import org.apache.lucene.analysis.TokenStream;
import org.apache.lucene.document.Document;
import org.apache.lucene.document.Fieldable;

public class Documents extends ArrayList<Document> {
  
  public Documents() {}
  
  public Documents(Collection<Document> documents) {
    for (Document document : documents) {
      add(document);
    }
  }
  
  public boolean hasFieldsWithTokenStreamOrReader() {
    for (Document document : this) {
      List fields = document.getFields();
      for (int x=0; x < fields.size(); x++) {
        Fieldable fieldable = (Fieldable)fields.get(x);
        TokenStream tokenStream = fieldable.tokenStreamValue();
        if (tokenStream != null) return true;
        Reader reader = fieldable.readerValue();
        if (reader != null) return true;
      }
    }
    return false;
  }
}
